import simplejson as json


class JsonObj:
    propDict = {}
    persistPath = ""
    
    def __init__(self, persistPath, propDict = None):
        self.persistPath = persistPath
        if propDict != None:
            self.propDict= propDict
            
    def load(self):
        with open(persistPath, "rb") as fp:
            self.propDict = json.load(fp)
            
    
    def save(self):
        with open(persistPath, "wb") as fp:
            json.dump(self.propDict, fp)
            
    def setProp(self, propKey, propVal, save=False):
        self.propDict[propKey] = propVal
        if save == True:
            self.save()
        
    def setProps(self, props, save = False):
        for k in props.keys():
            v = prop.get(k)
            self.propDict[k] = v
        
        if save == True:
            self.save()
        
    def getProp(self, propKey):
        return self.propDict.get(propKey)